package com.analyse.stock.enums;

import org.apache.commons.lang3.StringUtils;

public enum  BoardCategoryEnum {
    REGION_BOARD("m:90+t:1+f:!50","地域板块"),
    CONCEPT_BOARD("m:90+t:3+f:!50","概念板块"),
    INDUSTRY_BOARD("m:90+t:2+f:!50","行业板块")
    ;
    BoardCategoryEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    private final String code;
    private final String desc;

    public String getCode() {
        return this.code;
    }

    public String getName() {
        return this.desc;
    }

    public String getDesc() {
        return desc;
    }

    public static String getDescByCode(String code){
        if(StringUtils.isBlank(code)) {
            return StringUtils.EMPTY;
        }
        for (BoardCategoryEnum anEnum : values()) {
            if (anEnum.getCode().equalsIgnoreCase(code)){
                return anEnum.getDesc();
            }
        }
        return StringUtils.EMPTY;
    }

    public static String getByName(String name){
        if(StringUtils.isBlank(name)) {
            return StringUtils.EMPTY;
        }
        for (BoardCategoryEnum anEnum : values()) {
            if (anEnum.name().contains(name.toUpperCase())){
                return anEnum.getCode();
            }
        }
        return StringUtils.EMPTY;
    }
}
